package com.time.hellotime.components.popup;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.time.hellotime.R;
import com.time.hellotime.base.BasePW;


/**
 * 欢迎回来
 * Author: Created by deng on 2016/8/16.
 * E-mail: tx16bing@163.com
 */
public class WelBackPW extends BasePW{

    private Context mContext;

    public TextView tvTimeCoin;

    public WelBackPW(Context context, ViewGroup view) {
        this.mContext = context;
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View mView = inflater.inflate(R.layout.pw_welcome_back, view, false);
        assignViews(mView);
        setContentView(mView);
        setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
        setFocusable(true);
        setOutsideTouchable(true);
//        this.setAnimationStyle(R.style.CsbBank_Pw_Bottom_Animation);
        ColorDrawable dw = new ColorDrawable(0x80000000);
        this.setBackgroundDrawable(dw);
        mView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                dismiss();
                return true;
            }
        });
    }

    public void setTimeCoin(String time) {
        if (!TextUtils.isEmpty(time)){
            this.tvTimeCoin.setText("+" + time);
        }
    }

    private void assignViews(View mView) {
        tvTimeCoin = (TextView) mView.findViewById(R.id.tv_wel_back_time_coin);
        mView.findViewById(R.id.tv_wel_back_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

}
